/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * LoadMapDialog.java
 *
 * Created on Aug 18, 2011, 3:10:07 PM
 */
package designer.userinterface.forms;

import java.io.File;

/**
 *
 * @author timon
 */
public class LoadMapDialog extends javax.swing.JDialog {

    /** Creates new form LoadMapDialog */
    public LoadMapDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jfc_LoadMap = new javax.swing.JFileChooser();
        lbl_Intro = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jfc_LoadMap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jfc_LoadMapActionPerformed(evt);
            }
        });

        lbl_Intro.setFont(new java.awt.Font("Droid Sans", 1, 18));
        lbl_Intro.setText("Load a Map");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_Intro)
                    .addComponent(jfc_LoadMap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addComponent(lbl_Intro, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jfc_LoadMap, javax.swing.GroupLayout.PREFERRED_SIZE, 416, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jfc_LoadMapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jfc_LoadMapActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_jfc_LoadMapActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                LoadMapDialog dialog = new LoadMapDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    /**
     * Return the dungeon file chosen by the user.
     * 
     * @return 
     *   The user's selected file.
     */
    public File getChosenFile() {
        return jfc_LoadMap.getSelectedFile();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser jfc_LoadMap;
    private javax.swing.JLabel lbl_Intro;
    // End of variables declaration//GEN-END:variables
}
